/* $Id: ImagePane.java,v 1.4 2007/09/07 06:51:21 gigabass Exp $
*
* Copyright (c) Guido Ludwig. All rights reserved.
* Use is subject to license terms.
*/
package de.guidoludwig.af;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.JComponent;


public class ImagePane extends JComponent {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Image image;

    public ImagePane(Image i) {
        image = i;
        int width = image == null ? 300 : image.getWidth(null);
        int height = image == null ? 200 : image.getHeight(null);
        setPreferredSize(new Dimension(width, height));
        setBackground(Color.WHITE);
    }

    @Override
	public void paint(Graphics g) {
        if (image != null) {
            g.drawImage(image, 0, 0, this);
        }
    }
}